<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Gustuy
  Date: 2021/9/14
  Time: 11:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>关山小站</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/JS/jquery-3.6.0.js"></script>
    <script>
        function login(){
            window.location.replace("${pageContext.request.contextPath}/gologin")
        }
        function nopage(){
            alert("这个页面我还没写")
        }
        setInterval(function (){
            $.post({
                url: "${pageContext.request.contextPath}/getTime",
                success(data){
                    $("#timeshow").text(data)
                    console.log(data)
                }
            })
        },500)
        function getvalue(){
            $.post({
                url:"${pageContext.request.contextPath}/a1",
                data:{"Uid":$("#uid").val()},
                success:function (data){
                    console.log(data)
                    var tbalebody=""
                    tbalebody+="<tbody>"
                    for(let i=0;i<data.length;i++){
                        tbalebody+="<tr>"
                            +"<td>"+data[i].uid+"</td>"
                            +"<td>"+data[i].name+"</td>"
                            +"<td>"+data[i].sex+"</td>"
                            +"<td>"+data[i].phone+"</td>"
                            +"<td>"+data[i].email+"</td>"
                        +"</tr>"
                    }
                    tbalebody+="</tbody>"
                    $("#result").html("<thead><tr><td>Uid</td><td>姓名</td><td>性别</td><td>手机</td><td>Email</td></tr></thead>")
                    $("#result").append(tbalebody)
                },
                error:function (){
                    document.getElementById("resultspan").innerText="ajax失败"
                }
            })
        }
    </script>
</head>
<body>
<div id="bg" class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="text-center">
                关山小站
            </h3>
            <div class="col-xl-12"><p>&nbsp;</p></div>
            <div class="col-xl-12"><p>&nbsp;</p></div>
            <div class="col-xl-12"><p>&nbsp;</p></div>
            <div class="col-xl-12"><p>&nbsp;</p></div>
            <div class="col-xl-12"><p>&nbsp;</p></div>
            <div class="col-xl-12 text-center">
            <form class="form-inline">
                <input class="form-control" type="text" id="uid" onblur="getvalue()"/><button type="submit" class="btn">查找</button>
            </form>
                <span id="resultspan"></span>
                <div class="col-xl-12 text-center">
                <table id="result" class="table table-bordered table-hover table-striped">
                    <thead>
                    <tr>
                        <td>Uid</td>
                        <td>姓名</td>
                        <td>性别</td>
                        <td>手机</td>
                        <td>Email</td>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
                </div>
            </div>
            <div class="row-fluid">

                <div class="col-xs-6 text-center">
                    <h3>
                        在这里注册
                    </h3>
                    <button class="btn" type="button" onclick=login()>注册</button>
                </div>
                <div class="col-xs-6 text-center">
                    <h3>
                        在这里登录
                    </h3>
                    <button class="btn align-items-center" type="button" onclick=nopage()>登录</button>
                </div>
            </div>
        </div>
    </div>
    <hr/>
    <div class="text-center">
        <span id="timeshow"></span>
    </div>
    <form id="filefrom" enctype="multipart/form-data" role="form">
        <div class="form-group">
            
        </div>
    </form>
</div>
</body>
</html>
